import { defineStore } from "pinia";
import { ref ,computed} from "vue";


export const use_app_store = defineStore("app_store",()=>{
    const todoList = ref([
        {
          id:1001,
          title:"测试内容1",
          completed: false
        },
        {
          id:1002,
          title:"测试内容2",
          completed: false
        }
      ])

      //待完成任务
    const showClearCompleted = ref(false)
    const uncompleted = computed(()=>{
        let number =  todoList.value.filter(item => item.completed === false).length
        if(number != 0){
            showClearCompleted.value = true
        } else {
            showClearCompleted.value = false
        }

        return number
    })

    return {todoList,showClearCompleted,uncompleted}
},{
    persist:{
        enabled: true,
        storage: localStorage,
        paths:['todoList']

    }
})

